import math
import numpy
import png2obj.image
import png2obj.mesh
import png2obj.heightmap
import png2obj.contour
import png2obj.stardrive.hull

basename = "Sentinel"

imageData = png2obj.image.loadImage(basename + '.png')
slots = png2obj.stardrive.hull.imageData2Slots(imageData, ("O", "I", "E"))

# result = png2obj.contour.makeContour(png2obj.contour.addBorder(slots > 0))
# print(result)

numSlots = png2obj.stardrive.hull.countSlotRestrictionSets(slots)
area = float(sum(numSlots[1:]))
baseHeight = 1.0/4.0 * area**(1.0/2.0)

heights = [(0.0, 1.0), (baseHeight*0.25, math.sqrt(0.75)), (baseHeight*0.5, math.sqrt(0.5)), (baseHeight*0.75, math.sqrt(0.25)), (baseHeight, 0.0)]
mesh, placeholderTextureData = png2obj.contour.coneStyle(basename, slots, heights, placeholderScale = 4)
mesh.exportWavefront()
png2obj.image.saveImage(basename + "_d.png", placeholderTextureData)
